package com.study.demo.aop.demo;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;

/**
 * @author: elvin
 * @time: 2019-04-22 13:32
 * @desc:
 **/
public class StudentProxy {

    public void beforeTargetMethod(JoinPoint jp)  {

        for (Object arg : jp.getArgs()) {
            System.out.println(arg);
        }

        Object target = jp.getTarget();
        System.out.println(target);

        System.out.println("1. --- beforeTargetMethod ---");
    }

    public void afterTargetMethod() {
        System.out.println("2. --- afterTargetMethod ---");
    }

    public void afterThrowTargetMethod() {
        System.out.println("3. --- afterThrowTargetMethod ---");
    }

    public void afterReturnTargetMethod() {
        System.out.println("4. --- afterReturnTargetMethod ---");
    }

    public Object aroundTargetMethod(ProceedingJoinPoint pj) throws Throwable {
        System.out.println("5. --- aroundTargetMethod before  ---");
        Object proceed = pj.proceed();
        System.out.println("6. --- aroundTargetMethod after ---");
        return proceed;
    }
}
